# -*- coding:utf-8 -*-
#!/usr/bin/env python

import os
from time import sleep
from Tkinter import *

class DirList(object):
    def __init__(self,init_dir=None):
        self.root = Tk()
        self.label = Label(self.root,text="Directory Lister v1.1")
        self.label.pack()

        self.cwd = StringVar(self.root)

        self.dir1 = Label(self.root,fg="blue",font=('Helvetica',12,'bold'))
        self.dir1.pack()

        #定义Frame框架
        self.dirfm = Frame(self.root)
        #定义滚动条
        self.dirsb = Scrollbar(self.dirfm)
        self.dirsb.pack(side=RIGHT,fill=Y)
        #定义列表框
        self.dirs = Listbox(self.dirfm,height=15,width=50,yscrollcommand=self.dirsb.set)
        self.dirs.pack(side=LEFT,fill=BOTH)
        self.dirfm.pack()

        #定义输入框
        self.dirn = Entry(self.root,width=50,textvariable=self.cwd)
        self.dirn.pack()

        #定义按钮框架
        self.btfm = Frame(self.root)
        self.clr = Button(self.btfm,text="Clear",activeforeground="white",activebackground="blue")
        self.ls = Button(self.btfm,text="List Directory",activeforeground="white",activebackground="green")
        self.quit = Button(self.btfm,text="Quit",activeforeground="white",activebackground="red")
        self.clr.pack(side=LEFT)
        self.ls.pack(side=LEFT)
        self.quit.pack(side=LEFT)
        self.btfm.pack()

def main():
    DirList()
    mainloop()

if __name__ == '__main__':
    main()





